using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Text;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MySql.Data.MySqlClient;
using System.IO;



namespace Bass.Tools
{
    public class mytools
    {
        public string Substring(string str, int i, int j)
        {
            string resultstr = str.Substring(i, j);
            return resultstr;
        }

        public string ReformDate(string addtime)
        {
            string datereformed = Substring(addtime, 0, 4) + "-" + Substring(addtime, 4, 2) + "-" + Substring(addtime, 6, 2) + " " + Substring(addtime, 8, 2) + ":" + Substring(addtime, 10, 2);
            return datereformed;
        }

        public string getMysqlConn(string propertiesPath)
        {
            string mysqlid = "";
            string mysqlpassword = "";
            string mysqldatabase = "";


            StreamReader fileStream = new StreamReader(propertiesPath);
            while (!fileStream.EndOfStream)
            {
                string ms = fileStream.ReadLine();
                //Response.Write("<script>alert('" + ms + "');</script>");
                string[] sArray = ms.Split('=');
                if (sArray[0] == "id")
                {
                    mysqlid = sArray[1];
                }
                if (sArray[0] == "password")
                {
                    mysqlpassword = sArray[1];
                }
                if (sArray[0] == "database")
                {
                    mysqldatabase = sArray[1];
                }
            }
            fileStream.Close();

            string ConnString = "server=localhost;user id=" + mysqlid + ";password=" + mysqlpassword + ";database=" + mysqldatabase;
            return ConnString;
        }

    }
}
